<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="备注" prop="remarks">
        <el-input
          v-model="queryParams.remarks"
          placeholder="请输入备注"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="年度" prop="awardYear">
        <el-date-picker clearable
          v-model="queryParams.awardYear"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择年度">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="人员编号" prop="employeeId">
        <el-input
          v-model="queryParams.employeeId"
          placeholder="请输入人员编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="地市" prop="city">
        <el-input
          v-model="queryParams.city"
          placeholder="请输入地市"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工作单位" prop="workUnit">
        <el-input
          v-model="queryParams.workUnit"
          placeholder="请输入工作单位"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="专业" prop="profession">
        <el-input
          v-model="queryParams.profession"
          placeholder="请输入专业"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工作票编号" prop="ticketNumber">
        <el-input
          v-model="queryParams.ticketNumber"
          placeholder="请输入工作票编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否移动端" prop="isMobile">
        <el-input
          v-model="queryParams.isMobile"
          placeholder="请输入是否移动端"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="制票单位名称" prop="issuerUnitName">
        <el-input
          v-model="queryParams.issuerUnitName"
          placeholder="请输入制票单位名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="制票人名称" prop="issuerName">
        <el-input
          v-model="queryParams.issuerName"
          placeholder="请输入制票人名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="制票时间" prop="issueTime">
        <el-date-picker clearable
          v-model="queryParams.issueTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择制票时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="工作" prop="groupLeaderDepartment">
        <el-input
          v-model="queryParams.groupLeaderDepartment"
          placeholder="请输入工作"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工作" prop="groupLeaderName">
        <el-input
          v-model="queryParams.groupLeaderName"
          placeholder="请输入工作"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工作班组名称" prop="workTeamName">
        <el-input
          v-model="queryParams.workTeamName"
          placeholder="请输入工作班组名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="总人数" prop="totalMembers">
        <el-input
          v-model="queryParams.totalMembers"
          placeholder="请输入总人数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="运维单位名称" prop="operationUnitName">
        <el-input
          v-model="queryParams.operationUnitName"
          placeholder="请输入运维单位名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="维护班组名称" prop="maintenanceTeamName">
        <el-input
          v-model="queryParams.maintenanceTeamName"
          placeholder="请输入维护班组名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="电压等级名称" prop="voltageLevelName">
        <el-input
          v-model="queryParams.voltageLevelName"
          placeholder="请输入电压等级名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="电站名称" prop="stationName">
        <el-input
          v-model="queryParams.stationName"
          placeholder="请输入电站名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="线路名称" prop="lineName">
        <el-input
          v-model="queryParams.lineName"
          placeholder="请输入线路名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工作任务的变配电站或线路或设备名称" prop="taskLocationName">
        <el-input
          v-model="queryParams.taskLocationName"
          placeholder="请输入工作任务的变配电站或线路或设备名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="计划开始时间" prop="plannedStartTime">
        <el-date-picker clearable
          v-model="queryParams.plannedStartTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择计划开始时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="计划结束时间" prop="plannedEndTime">
        <el-date-picker clearable
          v-model="queryParams.plannedEndTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择计划结束时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="第一签发单位名称" prop="firstIssuerUnitName">
        <el-input
          v-model="queryParams.firstIssuerUnitName"
          placeholder="请输入第一签发单位名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="第一签发人班组" prop="firstIssuerTeamName">
        <el-input
          v-model="queryParams.firstIssuerTeamName"
          placeholder="请输入第一签发人班组"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="第一签发人名称" prop="firstIssuerName">
        <el-input
          v-model="queryParams.firstIssuerName"
          placeholder="请输入第一签发人名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="第一签发时间" prop="firstIssuerTime">
        <el-date-picker clearable
          v-model="queryParams.firstIssuerTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择第一签发时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="是否双签发" prop="isDoubleIssued">
        <el-input
          v-model="queryParams.isDoubleIssued"
          placeholder="请输入是否双签发"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="接票人班组名称" prop="receiverTeamName">
        <el-input
          v-model="queryParams.receiverTeamName"
          placeholder="请输入接票人班组名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="接票人签名" prop="receiverSignature">
        <el-input
          v-model="queryParams.receiverSignature"
          placeholder="请输入接票人签名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="运维人员签名" prop="operationPersonSignature">
        <el-input
          v-model="queryParams.operationPersonSignature"
          placeholder="请输入运维人员签名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="接票时间" prop="receiveTime">
        <el-date-picker clearable
          v-model="queryParams.receiveTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择接票时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="是否安全措施校验通过" prop="isSafetyMeasuresPassed">
        <el-input
          v-model="queryParams.isSafetyMeasuresPassed"
          placeholder="请输入是否安全措施校验通过"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="开工_工作负责人签名" prop="startWorkLeaderSignature">
        <el-input
          v-model="queryParams.startWorkLeaderSignature"
          placeholder="请输入开工_工作负责人签名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="开工经度" prop="startLongitude">
        <el-input
          v-model="queryParams.startLongitude"
          placeholder="请输入开工经度"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="开工纬度" prop="startLatitude">
        <el-input
          v-model="queryParams.startLatitude"
          placeholder="请输入开工纬度"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="开工地址" prop="startAddress">
        <el-input
          v-model="queryParams.startAddress"
          placeholder="请输入开工地址"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="实际工作开始时间" prop="actualStartTime">
        <el-date-picker clearable
          v-model="queryParams.actualStartTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择实际工作开始时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="是否延期" prop="isExtended">
        <el-input
          v-model="queryParams.isExtended"
          placeholder="请输入是否延期"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="实际工作完工时间" prop="actualCompletionTime">
        <el-date-picker clearable
          v-model="queryParams.actualCompletionTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择实际工作完工时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="工作票终结时间" prop="ticketTerminationTime">
        <el-date-picker clearable
          v-model="queryParams.ticketTerminationTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择工作票终结时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="是否归档" prop="isArchived">
        <el-input
          v-model="queryParams.isArchived"
          placeholder="请输入是否归档"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="存档人名称" prop="archiverName">
        <el-input
          v-model="queryParams.archiverName"
          placeholder="请输入存档人名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="存档时间" prop="archiveTime">
        <el-date-picker clearable
          v-model="queryParams.archiveTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择存档时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="取消或作废或未执行人员" prop="cancellationPersonName">
        <el-input
          v-model="queryParams.cancellationPersonName"
          placeholder="请输入取消或作废或未执行人员"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="取消或作废或未执行时间" prop="cancellationTime">
        <el-date-picker clearable
          v-model="queryParams.cancellationTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择取消或作废或未执行时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="工作终结时间" prop="workTerminationTime">
        <el-date-picker clearable
          v-model="queryParams.workTerminationTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择工作终结时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['business:workTicketInfo:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['business:workTicketInfo:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['business:workTicketInfo:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['business:workTicketInfo:export']"
        >导出</el-button>
      </el-col>

      <el-col :span="1.5">
            <el-button
              type="info"
              plain
              icon="el-icon-upload2"
              size="mini"
              @click="handleImport"
            >导入</el-button>
          </el-col>

      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="workTicketInfoList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="ID" align="center" prop="id" />
      <el-table-column label="备注" align="center" prop="remarks" />
      <el-table-column label="年度" align="center" prop="awardYear" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.awardYear, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="人员编号" align="center" prop="employeeId" />
      <el-table-column label="地市" align="center" prop="city" />
      <el-table-column label="工作单位" align="center" prop="workUnit" />
      <el-table-column label="工作票种类" align="center" prop="ticketType" />
      <el-table-column label="专业" align="center" prop="profession" />
      <el-table-column label="流程状态" align="center" prop="processStatus" />
      <el-table-column label="工作票编号" align="center" prop="ticketNumber" />
      <el-table-column label="是否移动端" align="center" prop="isMobile" />
      <el-table-column label="制票单位名称" align="center" prop="issuerUnitName" />
      <el-table-column label="制票人名称" align="center" prop="issuerName" />
      <el-table-column label="制票时间" align="center" prop="issueTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.issueTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="工作" align="center" prop="groupLeaderDepartment" />
      <el-table-column label="工作" align="center" prop="groupLeaderName" />
      <el-table-column label="工作班组名称" align="center" prop="workTeamName" />
      <el-table-column label="总人数" align="center" prop="totalMembers" />
      <el-table-column label="工作班成员名称" align="center" prop="teamMemberNames" />
      <el-table-column label="运维单位名称" align="center" prop="operationUnitName" />
      <el-table-column label="维护班组名称" align="center" prop="maintenanceTeamName" />
      <el-table-column label="电压等级名称" align="center" prop="voltageLevelName" />
      <el-table-column label="电站名称" align="center" prop="stationName" />
      <el-table-column label="线路名称" align="center" prop="lineName" />
      <el-table-column label="工作任务的变配电站或线路或设备名称" align="center" prop="taskLocationName" />
      <el-table-column label="工作任务的工作地点" align="center" prop="taskWorkLocation" />
      <el-table-column label="工作任务的工作内容" align="center" prop="taskWorkContent" />
      <el-table-column label="计划开始时间" align="center" prop="plannedStartTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.plannedStartTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="计划结束时间" align="center" prop="plannedEndTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.plannedEndTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="工作条件" align="center" prop="workConditions" />
      <el-table-column label="第一签发单位名称" align="center" prop="firstIssuerUnitName" />
      <el-table-column label="第一签发人班组" align="center" prop="firstIssuerTeamName" />
      <el-table-column label="第一签发人名称" align="center" prop="firstIssuerName" />
      <el-table-column label="第一签发时间" align="center" prop="firstIssuerTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.firstIssuerTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="是否双签发" align="center" prop="isDoubleIssued" />
      <el-table-column label="接票人班组名称" align="center" prop="receiverTeamName" />
      <el-table-column label="接票人签名" align="center" prop="receiverSignature" />
      <el-table-column label="运维人员签名" align="center" prop="operationPersonSignature" />
      <el-table-column label="接票时间" align="center" prop="receiveTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.receiveTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="是否安全措施校验通过" align="center" prop="isSafetyMeasuresPassed" />
      <el-table-column label="工作班成员签名" align="center" prop="teamMemberSignatures" />
      <el-table-column label="开工_工作负责人签名" align="center" prop="startWorkLeaderSignature" />
      <el-table-column label="开工经度" align="center" prop="startLongitude" />
      <el-table-column label="开工纬度" align="center" prop="startLatitude" />
      <el-table-column label="开工地址" align="center" prop="startAddress" />
      <el-table-column label="实际工作开始时间" align="center" prop="actualStartTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.actualStartTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="执行状态" align="center" prop="executionStatus" />
      <el-table-column label="是否延期" align="center" prop="isExtended" />
      <el-table-column label="实际工作完工时间" align="center" prop="actualCompletionTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.actualCompletionTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="工作票终结时间" align="center" prop="ticketTerminationTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.ticketTerminationTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="是否归档" align="center" prop="isArchived" />
      <el-table-column label="存档人名称" align="center" prop="archiverName" />
      <el-table-column label="存档时间" align="center" prop="archiveTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.archiveTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="取消或作废或未执行人员" align="center" prop="cancellationPersonName" />
      <el-table-column label="取消或作废或未执行原因" align="center" prop="cancellationReason" />
      <el-table-column label="取消或作废或未执行时间" align="center" prop="cancellationTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.cancellationTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="停电范围" align="center" prop="powerOutageScope" />
      <el-table-column label="工作终结时间" align="center" prop="workTerminationTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.workTerminationTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['business:workTicketInfo:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['business:workTicketInfo:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改工作票对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="备注" prop="remarks">
          <el-input v-model="form.remarks" placeholder="请输入备注" />
        </el-form-item>
        <el-form-item label="年度" prop="awardYear">
          <el-date-picker clearable
            v-model="form.awardYear"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择年度">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="人员编号" prop="employeeId">
          <el-input v-model="form.employeeId" placeholder="请输入人员编号" />
        </el-form-item>
        <el-form-item label="地市" prop="city">
          <el-input v-model="form.city" placeholder="请输入地市" />
        </el-form-item>
        <el-form-item label="工作单位" prop="workUnit">
          <el-input v-model="form.workUnit" placeholder="请输入工作单位" />
        </el-form-item>
        <el-form-item label="专业" prop="profession">
          <el-input v-model="form.profession" placeholder="请输入专业" />
        </el-form-item>
        <el-form-item label="工作票编号" prop="ticketNumber">
          <el-input v-model="form.ticketNumber" placeholder="请输入工作票编号" />
        </el-form-item>
        <el-form-item label="是否移动端" prop="isMobile">
          <el-input v-model="form.isMobile" placeholder="请输入是否移动端" />
        </el-form-item>
        <el-form-item label="制票单位名称" prop="issuerUnitName">
          <el-input v-model="form.issuerUnitName" placeholder="请输入制票单位名称" />
        </el-form-item>
        <el-form-item label="制票人名称" prop="issuerName">
          <el-input v-model="form.issuerName" placeholder="请输入制票人名称" />
        </el-form-item>
        <el-form-item label="制票时间" prop="issueTime">
          <el-date-picker clearable
            v-model="form.issueTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择制票时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="工作" prop="groupLeaderDepartment">
          <el-input v-model="form.groupLeaderDepartment" placeholder="请输入工作" />
        </el-form-item>
        <el-form-item label="工作" prop="groupLeaderName">
          <el-input v-model="form.groupLeaderName" placeholder="请输入工作" />
        </el-form-item>
        <el-form-item label="工作班组名称" prop="workTeamName">
          <el-input v-model="form.workTeamName" placeholder="请输入工作班组名称" />
        </el-form-item>
        <el-form-item label="总人数" prop="totalMembers">
          <el-input v-model="form.totalMembers" placeholder="请输入总人数" />
        </el-form-item>
        <el-form-item label="工作班成员名称" prop="teamMemberNames">
          <el-input v-model="form.teamMemberNames" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="运维单位名称" prop="operationUnitName">
          <el-input v-model="form.operationUnitName" placeholder="请输入运维单位名称" />
        </el-form-item>
        <el-form-item label="维护班组名称" prop="maintenanceTeamName">
          <el-input v-model="form.maintenanceTeamName" placeholder="请输入维护班组名称" />
        </el-form-item>
        <el-form-item label="电压等级名称" prop="voltageLevelName">
          <el-input v-model="form.voltageLevelName" placeholder="请输入电压等级名称" />
        </el-form-item>
        <el-form-item label="电站名称" prop="stationName">
          <el-input v-model="form.stationName" placeholder="请输入电站名称" />
        </el-form-item>
        <el-form-item label="线路名称" prop="lineName">
          <el-input v-model="form.lineName" placeholder="请输入线路名称" />
        </el-form-item>
        <el-form-item label="工作任务的变配电站或线路或设备名称" prop="taskLocationName">
          <el-input v-model="form.taskLocationName" placeholder="请输入工作任务的变配电站或线路或设备名称" />
        </el-form-item>
        <el-form-item label="工作任务的工作地点" prop="taskWorkLocation">
          <el-input v-model="form.taskWorkLocation" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="工作任务的工作内容">
          <editor v-model="form.taskWorkContent" :min-height="192"/>
        </el-form-item>
        <el-form-item label="计划开始时间" prop="plannedStartTime">
          <el-date-picker clearable
            v-model="form.plannedStartTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择计划开始时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="计划结束时间" prop="plannedEndTime">
          <el-date-picker clearable
            v-model="form.plannedEndTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择计划结束时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="工作条件" prop="workConditions">
          <el-input v-model="form.workConditions" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="第一签发单位名称" prop="firstIssuerUnitName">
          <el-input v-model="form.firstIssuerUnitName" placeholder="请输入第一签发单位名称" />
        </el-form-item>
        <el-form-item label="第一签发人班组" prop="firstIssuerTeamName">
          <el-input v-model="form.firstIssuerTeamName" placeholder="请输入第一签发人班组" />
        </el-form-item>
        <el-form-item label="第一签发人名称" prop="firstIssuerName">
          <el-input v-model="form.firstIssuerName" placeholder="请输入第一签发人名称" />
        </el-form-item>
        <el-form-item label="第一签发时间" prop="firstIssuerTime">
          <el-date-picker clearable
            v-model="form.firstIssuerTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择第一签发时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="是否双签发" prop="isDoubleIssued">
          <el-input v-model="form.isDoubleIssued" placeholder="请输入是否双签发" />
        </el-form-item>
        <el-form-item label="接票人班组名称" prop="receiverTeamName">
          <el-input v-model="form.receiverTeamName" placeholder="请输入接票人班组名称" />
        </el-form-item>
        <el-form-item label="接票人签名" prop="receiverSignature">
          <el-input v-model="form.receiverSignature" placeholder="请输入接票人签名" />
        </el-form-item>
        <el-form-item label="运维人员签名" prop="operationPersonSignature">
          <el-input v-model="form.operationPersonSignature" placeholder="请输入运维人员签名" />
        </el-form-item>
        <el-form-item label="接票时间" prop="receiveTime">
          <el-date-picker clearable
            v-model="form.receiveTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择接票时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="是否安全措施校验通过" prop="isSafetyMeasuresPassed">
          <el-input v-model="form.isSafetyMeasuresPassed" placeholder="请输入是否安全措施校验通过" />
        </el-form-item>
        <el-form-item label="工作班成员签名" prop="teamMemberSignatures">
          <el-input v-model="form.teamMemberSignatures" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="开工_工作负责人签名" prop="startWorkLeaderSignature">
          <el-input v-model="form.startWorkLeaderSignature" placeholder="请输入开工_工作负责人签名" />
        </el-form-item>
        <el-form-item label="开工经度" prop="startLongitude">
          <el-input v-model="form.startLongitude" placeholder="请输入开工经度" />
        </el-form-item>
        <el-form-item label="开工纬度" prop="startLatitude">
          <el-input v-model="form.startLatitude" placeholder="请输入开工纬度" />
        </el-form-item>
        <el-form-item label="开工地址" prop="startAddress">
          <el-input v-model="form.startAddress" placeholder="请输入开工地址" />
        </el-form-item>
        <el-form-item label="实际工作开始时间" prop="actualStartTime">
          <el-date-picker clearable
            v-model="form.actualStartTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择实际工作开始时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="是否延期" prop="isExtended">
          <el-input v-model="form.isExtended" placeholder="请输入是否延期" />
        </el-form-item>
        <el-form-item label="实际工作完工时间" prop="actualCompletionTime">
          <el-date-picker clearable
            v-model="form.actualCompletionTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择实际工作完工时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="工作票终结时间" prop="ticketTerminationTime">
          <el-date-picker clearable
            v-model="form.ticketTerminationTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择工作票终结时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="是否归档" prop="isArchived">
          <el-input v-model="form.isArchived" placeholder="请输入是否归档" />
        </el-form-item>
        <el-form-item label="存档人名称" prop="archiverName">
          <el-input v-model="form.archiverName" placeholder="请输入存档人名称" />
        </el-form-item>
        <el-form-item label="存档时间" prop="archiveTime">
          <el-date-picker clearable
            v-model="form.archiveTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择存档时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="取消或作废或未执行人员" prop="cancellationPersonName">
          <el-input v-model="form.cancellationPersonName" placeholder="请输入取消或作废或未执行人员" />
        </el-form-item>
        <el-form-item label="取消或作废或未执行原因" prop="cancellationReason">
          <el-input v-model="form.cancellationReason" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="取消或作废或未执行时间" prop="cancellationTime">
          <el-date-picker clearable
            v-model="form.cancellationTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择取消或作废或未执行时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="停电范围" prop="powerOutageScope">
          <el-input v-model="form.powerOutageScope" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="工作终结时间" prop="workTerminationTime">
          <el-date-picker clearable
            v-model="form.workTerminationTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择工作终结时间">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 用户导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <div class="el-upload__tip" slot="tip">
            <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
          </div>
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import { listWorkTicketInfo, getWorkTicketInfo, delWorkTicketInfo, addWorkTicketInfo, updateWorkTicketInfo } from "@/api/business/workTicketInfo";
import { getToken } from "@/utils/auth";

export default {
  name: "WorkTicketInfo",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 工作票表格数据
      workTicketInfoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        remarks: null,
        awardYear: null,
        employeeId: null,
        city: null,
        workUnit: null,
        ticketType: null,
        profession: null,
        processStatus: null,
        ticketNumber: null,
        isMobile: null,
        issuerUnitName: null,
        issuerName: null,
        issueTime: null,
        groupLeaderDepartment: null,
        groupLeaderName: null,
        workTeamName: null,
        totalMembers: null,
        teamMemberNames: null,
        operationUnitName: null,
        maintenanceTeamName: null,
        voltageLevelName: null,
        stationName: null,
        lineName: null,
        taskLocationName: null,
        taskWorkLocation: null,
        taskWorkContent: null,
        plannedStartTime: null,
        plannedEndTime: null,
        workConditions: null,
        firstIssuerUnitName: null,
        firstIssuerTeamName: null,
        firstIssuerName: null,
        firstIssuerTime: null,
        isDoubleIssued: null,
        receiverTeamName: null,
        receiverSignature: null,
        operationPersonSignature: null,
        receiveTime: null,
        isSafetyMeasuresPassed: null,
        teamMemberSignatures: null,
        startWorkLeaderSignature: null,
        startLongitude: null,
        startLatitude: null,
        startAddress: null,
        actualStartTime: null,
        executionStatus: null,
        isExtended: null,
        actualCompletionTime: null,
        ticketTerminationTime: null,
        isArchived: null,
        archiverName: null,
        archiveTime: null,
        cancellationPersonName: null,
        cancellationReason: null,
        cancellationTime: null,
        powerOutageScope: null,
        workTerminationTime: null
      },
      // 表单参数
      form: {},
      // 用户导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/business/workTicketInfo/importData"
      },
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询工作票列表 */
    getList() {
      this.loading = true;
      listWorkTicketInfo(this.queryParams).then(response => {
        this.workTicketInfoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        remarks: null,
        awardYear: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        employeeId: null,
        city: null,
        workUnit: null,
        ticketType: null,
        profession: null,
        processStatus: null,
        ticketNumber: null,
        isMobile: null,
        issuerUnitName: null,
        issuerName: null,
        issueTime: null,
        groupLeaderDepartment: null,
        groupLeaderName: null,
        workTeamName: null,
        totalMembers: null,
        teamMemberNames: null,
        operationUnitName: null,
        maintenanceTeamName: null,
        voltageLevelName: null,
        stationName: null,
        lineName: null,
        taskLocationName: null,
        taskWorkLocation: null,
        taskWorkContent: null,
        plannedStartTime: null,
        plannedEndTime: null,
        workConditions: null,
        firstIssuerUnitName: null,
        firstIssuerTeamName: null,
        firstIssuerName: null,
        firstIssuerTime: null,
        isDoubleIssued: null,
        receiverTeamName: null,
        receiverSignature: null,
        operationPersonSignature: null,
        receiveTime: null,
        isSafetyMeasuresPassed: null,
        teamMemberSignatures: null,
        startWorkLeaderSignature: null,
        startLongitude: null,
        startLatitude: null,
        startAddress: null,
        actualStartTime: null,
        executionStatus: null,
        isExtended: null,
        actualCompletionTime: null,
        ticketTerminationTime: null,
        isArchived: null,
        archiverName: null,
        archiveTime: null,
        cancellationPersonName: null,
        cancellationReason: null,
        cancellationTime: null,
        powerOutageScope: null,
        workTerminationTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加工作票";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getWorkTicketInfo(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改工作票";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateWorkTicketInfo(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addWorkTicketInfo(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除工作票编号为"' + ids + '"的数据项？').then(function() {
        return delWorkTicketInfo(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('business/workTicketInfo/export', {
        ...this.queryParams
      }, `workTicketInfo_${new Date().getTime()}.xlsx`)
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "用户导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('business/workTicketInfo/importTemplate', {
      }, `workTicketInfo_template_${new Date().getTime()}.xlsx`)
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    }
  }
};
</script>
